package a;

import java.io.IOException;
import java.util.Iterator;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class ExchangerateComFetcher extends ExchangeRateFetcher {
	@Override
	public void fetch() {
		try {
			Document doc = Jsoup.connect("http://www.exchangerate.com/Currency_Rates_September_01_2011.html").timeout(60000).get();

			Iterator<Element> erCells = doc.select("#BodyTable .ttsb").iterator();
			Element e;
			while(erCells.hasNext()&&(e=erCells.next())!=null) {
				this.setRate(e.previousElementSibling().previousElementSibling().text().trim(), Float.parseFloat(e.text()),"USD");
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
}
